#ifndef RS485_1_TX_THREAD_H
#define RS485_1_TX_THREAD_H

#include <QObject>
#include <QMutex>
#include <QDebug>
#include <QThread>
#include <QSemaphore>

#include "serial_port/serial_port.h"

namespace  {
    QSemaphore rs485_1_tx_sem(1);
}


class RS485_1_Tx_Thread : public QObject
{
    Q_OBJECT
public:
    RS485_1_Tx_Thread(Serial_Port* sp = nullptr);
    ~RS485_1_Tx_Thread();

    void stop_thread();

signals:
    void signal_start_tx_thread();
    void signal_start_rs485_1_port(char *s,int len);

public slots:
    void slot_rs485_1_port_tx_thread();
    void slot_write_rs485_1_port_tx_queue(char *s, unsigned int len);
    void slot_tx_semaphore_release(qint64 bytes);

private:
    bool stop_flag;
    QMutex stop_mutex;
    Serial_Port *serial_port;
};





#endif
